
var school = new Vue({
	el: '#school',
	data: {
		school: {},
		show: true
	}
})

var teachers = new Vue({
	el: '#teachers',
	data: {

	}
})

var students = new Vue({
	el: '#students',
	data: {

	}
})

function update_tab (index) {
	school.$set('show', index == 0)
	teachers.$set('show', index == 1)
	students.$set('show', index == 2)
}

var currentTab = Cookies.get('current')
currentTab = currentTab ? currentTab : 0
update_tab(currentTab)

var navbar = new Vue({
	el: '#navbar',
	data: {
		tabs: ['概况', '教师', '学生'],
		brand_url: '/school',
		current: currentTab,
	},
	methods: {
		clickTabs: function (index) {
			this.$set('current', index)
			update_tab(index)
			Cookies.set('current', index)
		}
	}
})
// navbar.$set('tabs', ['概况', '教师', '学生'])

Vue.http.get('/school/detail-data', {
	params: {
		id: _P('id')
	}
}).then(function(res) {
	var schooldata = res.data.school[0]
	navbar.$set('brand', schooldata.fields.nick)
	school.$set('school', schooldata)
}, function(res) {

})

Vue.http.get('/school/teachers', {
	params: {
		id: _P('id')
	}
}).then(function(res) {
	teachers.$set('teachers', res.data.teachers)
}, function(err) {

})

Vue.http.get('/school/students', {
	params: {
		id: _P('id')
	}
}).then(function(res) {
	students.$set('students', res.data.students)
}, function(err) {

})